﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using mobliebo;
namespace mobileshopping
{
    public partial class _Default : System.Web.UI.Page
    {
       company_info mobl = new company_info();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = mobl.GetRecords(-99, "", "", "", "",-99, false, " and ");
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }



        protected void Button1_Click(object sender, EventArgs e)
        {
            mobl.company_id = -99;
            mobl.company_name = companyname.Text;
            mobl.brand_name = brandname.Text;
            mobl.services = services.Text;
            mobl.category = category.Text;
            mobl.launch_year = Convert.ToInt64(DropDownList1.SelectedItem.Value.ToString());
            mobl.is_deleted = false;
            mobl.SaveRecords();
            Response.Redirect("~/Default.aspx");
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DELETE")
            {
                DataTable dt = mobl.GetRecords(Convert.ToInt64(e.CommandArgument), "", "", "", "", 1800, false," and " );
                mobl.company_id = Convert.ToInt64(dt.Rows[0]["company_id"].ToString());
                mobl.company_name = dt.Rows[0]["company_id"].ToString();
                mobl.brand_name = dt.Rows[0]["brand_name"].ToString();
                mobl.services = dt.Rows[0]["services"].ToString();
                mobl.category = dt.Rows[0]["category"].ToString();
                mobl.launch_year = Convert.ToInt64(dt.Rows[0]["launch_year"].ToString());
                mobl.is_deleted = true;
                mobl.SaveRecords();
                Response.Redirect("~/Default.aspx");

            }


        }
    }
}

